package com.smarttiger.zero.admin.dao;

import com.smarttiger.zero.admin.entity.UsersGroupModel;
import com.smarttiger.zero.admin.entity.UsersModel;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface UsersDao extends BaseDao<UsersModel> {
    public UsersModel findByToken(String token);
    public UsersModel findByUserNameAndPassword(String userName,String password);
    public List<UsersModel> findAllByUserName(String userName);

    @Query("select ug from UsersGroupModel ug " +
            "left join UsersUsersGroupModel uug on ug.id = uug.userGroupId " +
            "left join UsersModel u on u.id = uug.usersId " +
            "where u.id = ?1 ")
    public List<UsersGroupModel> findGroupByUserId(String userId);

}
